package com.smalls.newvideotwo.mvp.model;

import com.google.gson.GsonBuilder;
import com.smalls.newvideotwo.db.Album;
import com.smalls.newvideotwo.db.VodDao;
import com.smalls.newvideotwo.mvp.base.BaseBeanResult;
import com.smalls.newvideotwo.mvp.bean.SearchByNameBean;
import com.smalls.newvideotwo.mvp.beanResult.SearchByNameResult;
import com.smalls.newvideotwo.mvp.model.modelInterface.ISearchByNameModel;
import com.smalls.newvideotwo.utils.Constant;

import java.util.List;

public class SearchByNameModel implements ISearchByNameModel {
    private static String TAG = Constant.baddcoolio2tag? Constant.TAGPREFIXSTR + "SearchByNameModel":"SearchByNameModel";
    private int requestTime = 1;

    public void searchByName(final String searchByNameBean,final String type, final BaseBeanResult baseBeanResult) {
        VodDao vodDao = new VodDao();
        List<Album> albumList = vodDao.queryAlbumByCategoryIdAndPinyin(searchByNameBean,type);
        SearchByNameResult searchByNameResult = new SearchByNameResult();
        searchByNameResult.setmAlbumList(albumList);
        searchByNameResult.setType(type);
        searchByNameResult.setSearchStr(searchByNameBean);
        if(albumList!=null) {
            baseBeanResult.onNext(searchByNameResult);
        } else {
            baseBeanResult.onError(new Throwable());
        }
    }
}
